package com.qianniu.napi.admin.task;

import com.qianniu.napi.common.util.ShellUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Configuration
@Component // 此注解必加
@EnableScheduling // 此注解必加
public class ShellTask {

    private static final Logger logger = LoggerFactory.getLogger(ShellTask.class);

    @Scheduled(cron = "0 0 0/1 * * ?")
    public void tidyTmp() {

        try {

        logger.debug(">>>ShellTask tidyTmp start");
        ShellUtil.execShell("rm -f /tmp/*.db");
//        ShellUtil.execShell("rm -fr /tmp/undertow-docbase.*");
//        ShellUtil.execShell("rm -fr /tmp/tomcat-docbase.*");

        }catch (Exception e){
            logger.error("======tidyTmp error",e);
        }
        logger.debug(">>>ShellTask tidyTmp over");
    }

}
